package main

import (
	"flag"
	"fmt"

	"gitee.com/thubcc/p2pgit/classedpack"
	"gitee.com/thubcc/p2pgit/some"
	"gitee.com/thubcc/p2pgit/types"
)

var argDir = flag.String("d", "../temp", "new pack dir")

func main() {
	flag.Parse()
	var err error
	var gs, ogs types.SomeGeter
	gs, err = some.GeterFromDir(*argDir)
	if err != nil {
		fmt.Println(*argDir, err)
		return
	}

	ogs, err = some.MergeGeters(gs)
	for _, v := range ogs {
		if cpf, ok := v.(*classedpack.File); ok {
			fmt.Println(cpf.Name())
		} else {
			fmt.Println(*argDir)
		}
	}
	ps := some.Geter2Rawer(gs)
	for _, v := range ps {
		if cpf, ok := v.(*classedpack.File); ok {
			fmt.Println(cpf.Name())
		} else {
			fmt.Println(*argDir)
		}
	}
	var toDel types.Rawer
	ps, toDel, err = ps.SplitK(0)
	if err != nil {
		fmt.Println(err)
	}
	if cpf, ok := toDel.(*classedpack.File); ok {
		fmt.Println(cpf.Name())
	} else {
		fmt.Println(*argDir)
	}
}
